import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:wowhy/service_locator.dart';
import 'package:wowhy/services/navigate_service.dart';

import 'action.dart';
import 'state.dart';

Widget buildView(
  SearchState state,
  Dispatch dispatch,
  ViewService viewService,
) {
  return Scaffold(
    appBar: AppBar(
      leading: InkWell(
        child: Icon(
          Icons.close,
        ),
        onTap: () {
          getIt<NavigateService>().pop(false);
        },
      ),
      title: Container(
        child: TextField(
          controller: state.queryController,
          autofocus: true,
          style: TextStyle(
            color: Colors.white,
          ),
          cursorColor: Colors.white,
          decoration: InputDecoration(
            hintText: '请输入搜索内容',
            border: InputBorder.none,
            hintStyle: TextStyle(color: Colors.white30),
          ),
          onSubmitted: (val) {
            dispatch(SearchActionCreator.query());
          },
        ),
      ),
      actions: <Widget>[
        IconButton(
          icon: Icon(Icons.search),
          onPressed: () {
            dispatch(SearchActionCreator.query());
          },
        )
      ],
    ),
    body: Container(),
  );
}
